<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:cc="http://java.sun.com/jsf/composite">

    <!-- INTERFACE -->
    <cc:interface>
        <cc:attribute name="id" /> 
        <cc:attribute name="title" /> 
        <cc:attribute name="labelPesquisa" /> 
        <cc:attribute name="labelCadastro" /> 
        <cc:attribute name="label" required="true" /> 
        <cc:attribute name="idDialogPesquisa" required="true" /> 
        <cc:attribute name="idDialogCadastro" /> 
        <cc:attribute name="styleClassLabel" default="labels" /> 
        <cc:attribute name="styleClassInput" default="inputReadonly" /> 
        <cc:attribute name="styleClassError" default="errors" /> 
        <cc:attribute name="size" type="int" default="15" /> 
        <cc:attribute name="valid" type="boolean" default="true" />
        <cc:attribute name="required" type="boolean" /> 
        <cc:attribute name="value" />
    </cc:interface>

    <!-- IMPLEMENTATION -->
    <cc:implementation>
        <c:set var="cid" value="#{cc.attrs.id}_text" />
        <c:set var="labelCadastro" value="#{!empty cc.attrs.labelCadastro ? cc.attrs.labelCadastro : msgs['acao.criar']}" />
        <c:set var="labelPesquisa" value="#{!empty cc.attrs.labelPesquisa ? cc.attrs.labelPesquisa : msgs['acao.pesquisar']}" />
        <h:outputLabel for="#{cid}" value="#{cc.attrs.label}" styleClass="#{cc.attrs.styleClassLabel}" />
        <h:panelGrid columns="10">
            <f:validateBean disabled="#{!cc.attrs.valid}">
                <h:inputText id="#{cid}" label="#{cc.attrs.label}"
                             title="#{cc.attrs.valid and !jsfManager.valid(cid) ? jsfManager.getErrorMsg(cid) : (empty cc.attrs.title ? cc.attrs.label : cc.attrs.title)}"
                             styleClass="ui-inputfield ui-state-default ui-corner-all #{cc.attrs.valid and !jsfManager.valid(cid) ? cc.attrs.styleClassError : cc.attrs.styleClassInput}"
                             readonly="true" maxlength="0" size="#{cc.attrs.size}"
                             value="#{cc.attrs.value}" onclick="#{cc.attrs.idDialogPesquisa}_widvar.show();" />
            </f:validateBean>
            <p:commandLink oncomplete="#{cc.attrs.idDialogPesquisa}_widvar.show();">
                <h:graphicImage library="images" name="search.png" width="18" style="padding: 3px 0 0 4px;"
                                alt="#{labelPesquisa}" title="#{labelPesquisa}" />
            </p:commandLink>
            <p:commandLink rendered="#{!empty cc.attrs.idDialogCadastro}" oncomplete="#{cc.attrs.idDialogCadastro}_widvar.show();">
                <h:graphicImage library="images" name="add.png" width="18" style="padding: 3px 0 0 3px;"
                                alt="#{labelCadastro}" title="#{labelCadastro}" />
            </p:commandLink>
            <cc:insertChildren />
            <h:graphicImage rendered="#{cc.attrs.required}" library="images" name="required.gif" styleClass="imgCampoObrigatorio" />
        </h:panelGrid>
    </cc:implementation>
</html>